import 'dart:io';

import 'package:dio/dio.dart';
import 'package:wu_you/utils/logger_util.dart';

import 'login_util.dart';

class ErrorHandler {
  static void handleError(error, {Function(String msg) action}) {
    LoggerUtil.d(error.toString());
    if (error is DioError) {
      var response = error.response;
      if (response != null && response.statusCode == HttpStatus.unauthorized) {
        // LoginUtil.logout();
      }
      action?.call(error.error);
      return;
    }
    action?.call("请求错误，请稍后再试");
  }
}
